//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS IoTFleetHub service.
///
/// With Fleet Hub for IoT Device Management you can build stand-alone web applications for monitoring the health of your device fleets.
public struct IoTFleetHub: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the IoTFleetHub client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "IoTFleetHub",
            serviceIdentifier: "api.fleethub.iot",
            signingName: "iotfleethub",
            serviceProtocol: .restjson,
            apiVersion: "2020-11-03",
            endpoint: endpoint,
            variantEndpoints: Self.variantEndpoints,
            errorType: IoTFleetHubErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }




    /// FIPS and dualstack endpoints
    static var variantEndpoints: [EndpointVariantType: AWSServiceConfig.EndpointVariant] {[
        [.fips]: .init(endpoints: [
            "ca-central-1": "api.fleethub.iot-fips.ca-central-1.amazonaws.com",
            "us-east-1": "api.fleethub.iot-fips.us-east-1.amazonaws.com",
            "us-east-2": "api.fleethub.iot-fips.us-east-2.amazonaws.com",
            "us-west-2": "api.fleethub.iot-fips.us-west-2.amazonaws.com"
        ])
    ]}

    // MARK: API Calls

    /// Creates a Fleet Hub for IoT Device Management web application. When creating a Fleet Hub application, you must create an organization instance of IAM Identity Center if you don't already have one. The Fleet Hub application you create must also be in the same Amazon Web Services Region of the organization instance of IAM Identity Center. For more information see Enabling IAM Identity Center and Organization instances of IAM Identity Center.
    @Sendable
    @inlinable
    public func createApplication(_ input: CreateApplicationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateApplicationResponse {
        try await self.client.execute(
            operation: "CreateApplication", 
            path: "/applications", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Creates a Fleet Hub for IoT Device Management web application. When creating a Fleet Hub application, you must create an organization instance of IAM Identity Center if you don't already have one. The Fleet Hub application you create must also be in the same Amazon Web Services Region of the organization instance of IAM Identity Center. For more information see Enabling IAM Identity Center and Organization instances of IAM Identity Center.
    ///
    /// Parameters:
    ///   - applicationDescription: An optional description of the web application.
    ///   - applicationName: The name of the web application.
    ///   - clientToken: A unique case-sensitive identifier that you can provide to ensure the idempotency of the request.  Don't reuse this client token if a new idempotent request is required.
    ///   - roleArn: The ARN of the role that the web application assumes when it interacts with Amazon Web Services IoT Core.  The name of the role must be in the form AWSIotFleetHub_random_string .
    ///   - tags: A set of key/value pairs that you can use to manage the web application resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func createApplication(
        applicationDescription: String? = nil,
        applicationName: String,
        clientToken: String? = CreateApplicationRequest.idempotencyToken(),
        roleArn: String,
        tags: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateApplicationResponse {
        let input = CreateApplicationRequest(
            applicationDescription: applicationDescription, 
            applicationName: applicationName, 
            clientToken: clientToken, 
            roleArn: roleArn, 
            tags: tags
        )
        return try await self.createApplication(input, logger: logger)
    }

    /// Deletes a Fleet Hub for IoT Device Management web application.
    @Sendable
    @inlinable
    public func deleteApplication(_ input: DeleteApplicationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteApplicationResponse {
        try await self.client.execute(
            operation: "DeleteApplication", 
            path: "/applications/{applicationId}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes a Fleet Hub for IoT Device Management web application.
    ///
    /// Parameters:
    ///   - applicationId: The unique Id of the web application.
    ///   - clientToken: A unique case-sensitive identifier that you can provide to ensure the idempotency of the request.  Don't reuse this client token if a new idempotent request is required.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteApplication(
        applicationId: String,
        clientToken: String? = DeleteApplicationRequest.idempotencyToken(),
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteApplicationResponse {
        let input = DeleteApplicationRequest(
            applicationId: applicationId, 
            clientToken: clientToken
        )
        return try await self.deleteApplication(input, logger: logger)
    }

    /// Gets information about a Fleet Hub for IoT Device Management web application.
    @Sendable
    @inlinable
    public func describeApplication(_ input: DescribeApplicationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DescribeApplicationResponse {
        try await self.client.execute(
            operation: "DescribeApplication", 
            path: "/applications/{applicationId}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Gets information about a Fleet Hub for IoT Device Management web application.
    ///
    /// Parameters:
    ///   - applicationId: The unique Id of the web application.
    ///   - logger: Logger use during operation
    @inlinable
    public func describeApplication(
        applicationId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DescribeApplicationResponse {
        let input = DescribeApplicationRequest(
            applicationId: applicationId
        )
        return try await self.describeApplication(input, logger: logger)
    }

    /// Gets a list of Fleet Hub for IoT Device Management web applications for the current account.
    @Sendable
    @inlinable
    public func listApplications(_ input: ListApplicationsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListApplicationsResponse {
        try await self.client.execute(
            operation: "ListApplications", 
            path: "/applications", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Gets a list of Fleet Hub for IoT Device Management web applications for the current account.
    ///
    /// Parameters:
    ///   - nextToken: A token used to get the next set of results.
    ///   - logger: Logger use during operation
    @inlinable
    public func listApplications(
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListApplicationsResponse {
        let input = ListApplicationsRequest(
            nextToken: nextToken
        )
        return try await self.listApplications(input, logger: logger)
    }

    /// Lists the tags for the specified resource.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceResponse {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists the tags for the specified resource.
    ///
    /// Parameters:
    ///   - resourceArn: The ARN of the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceResponse {
        let input = ListTagsForResourceRequest(
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Adds to or modifies the tags of the specified resource. Tags are metadata which can be used to manage a resource.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> TagResourceResponse {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds to or modifies the tags of the specified resource. Tags are metadata which can be used to manage a resource.
    ///
    /// Parameters:
    ///   - resourceArn: The ARN of the resource.
    ///   - tags: The new or modified tags for the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        tags: [String: String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> TagResourceResponse {
        let input = TagResourceRequest(
            resourceArn: resourceArn, 
            tags: tags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Removes the specified tags (metadata) from the resource.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UntagResourceResponse {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Removes the specified tags (metadata) from the resource.
    ///
    /// Parameters:
    ///   - resourceArn: The ARN of the resource.
    ///   - tagKeys: A list of the keys of the tags to be removed from the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        tagKeys: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UntagResourceResponse {
        let input = UntagResourceRequest(
            resourceArn: resourceArn, 
            tagKeys: tagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }

    /// Updates information about a Fleet Hub for IoT Device Management web application.
    @Sendable
    @inlinable
    public func updateApplication(_ input: UpdateApplicationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpdateApplicationResponse {
        try await self.client.execute(
            operation: "UpdateApplication", 
            path: "/applications/{applicationId}", 
            httpMethod: .PATCH, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Updates information about a Fleet Hub for IoT Device Management web application.
    ///
    /// Parameters:
    ///   - applicationDescription: An optional description of the web application.
    ///   - applicationId: The unique Id of the web application.
    ///   - applicationName: The name of the web application.
    ///   - clientToken: A unique case-sensitive identifier that you can provide to ensure the idempotency of the request.  Don't reuse this client token if a new idempotent request is required.
    ///   - logger: Logger use during operation
    @inlinable
    public func updateApplication(
        applicationDescription: String? = nil,
        applicationId: String,
        applicationName: String? = nil,
        clientToken: String? = UpdateApplicationRequest.idempotencyToken(),
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpdateApplicationResponse {
        let input = UpdateApplicationRequest(
            applicationDescription: applicationDescription, 
            applicationId: applicationId, 
            applicationName: applicationName, 
            clientToken: clientToken
        )
        return try await self.updateApplication(input, logger: logger)
    }
}

extension IoTFleetHub {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: IoTFleetHub, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension IoTFleetHub {
    /// Return PaginatorSequence for operation ``listApplications(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listApplicationsPaginator(
        _ input: ListApplicationsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListApplicationsRequest, ListApplicationsResponse> {
        return .init(
            input: input,
            command: self.listApplications,
            inputKey: \ListApplicationsRequest.nextToken,
            outputKey: \ListApplicationsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listApplications(_:logger:)``.
    ///
    /// - Parameters:
    ///   - logger: Logger used for logging
    @inlinable
    public func listApplicationsPaginator(
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListApplicationsRequest, ListApplicationsResponse> {
        let input = ListApplicationsRequest(
        )
        return self.listApplicationsPaginator(input, logger: logger)
    }
}

extension IoTFleetHub.ListApplicationsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> IoTFleetHub.ListApplicationsRequest {
        return .init(
            nextToken: token
        )
    }
}
